package com.tanhua.server.controller;

import com.tanhua.server.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/user")
public class LoginController {

    @Autowired
    private UserService userService;


    /**
     * 获取登录验证码
     *   请求参数：phone （Map）
     *   响应：void
     * ResponseEntity
     */
    @PostMapping("/login")
    public ResponseEntity login(@RequestBody Map map){
        userService.sendMessage(map);
        return ResponseEntity.ok(null);
    }

    /**    * 检验登录
     */
    @PostMapping("/loginVerification")
    public ResponseEntity loginVerification(@RequestBody Map map){
        String phone = (String) map.get("phone");
        String verificationCode = (String) map.get("verificationCode");
        Map yuming = userService.loginVerification(phone, verificationCode);
        return ResponseEntity.ok(yuming);
    }



}
